require './Bond'

class Atom
  attr_accessor :bonds

  def initialize(adjacentAtomsArray=nil)
    @bonds = Array.new
    if !adjacentAtomsArray.nil? then
      adjacentAtomsArray.each do |adjacentAtom|
        bind(self,adjacentAtom)
      end
    end
  end
  
  def getBonds()
    return bonds
  end
  
  def getAdjacentAtoms
    adjacentAtoms  = Array.new;
    bonds.each do |bond|
      atom = bond.getAtomAtOtherEndOfBond(self);
      adjacentAtoms.push(atom);
    end
    return adjacentAtoms;
  end    
  
  private
  def bind(atom1,atom2)
    bond = Bond.new(atom1,atom2);
    atom1.bonds.push(bond);
    atom2.bonds.push(bond);
  end
end